@import '../../../styles/mixins';

$label_position_offset: 8px;
$series_container_width: 1.5rem;
$glyph_height: 23px; // Based on .funnel-step-glyph

.FunnelBarHorizontal {
    min-height: 100%;
    padding: 1rem;

    .InsightCard & {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .funnel-step {
        position: relative;
        padding-left: $series_container_width + 0.5rem;

        &:not(:first-child) {
            &,
            .funnel-series-container {
                padding-top: 0.75rem;
            }
        }

        .graph-series-glyph {
            z-index: 2;
        }

        .funnel-conversion-metadata {
            display: flex;
            align-items: center;
            justify-content: space-between;

            .funnel-inspect-button {
                line-height: 1.5rem;

                .value-inspector-button-icon {
                    margin-right: 0.25rem;
                    font-size: 1.5rem;
                    vertical-align: bottom;
                }
            }
        }

        .funnel-series-container {
            position: absolute;
            top: 0;
            left: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            width: $series_container_width;
            height: 100%;

            .graph-series-glyph {
                user-select: none;
            }

            .funnel-series-linebox {
                position: absolute;
                left: 0;
                box-sizing: border-box;
                width: calc(#{$series_container_width} / 2 + 1px);
                border-right: 2px solid var(--border);
                opacity: 0.5;

                &.before {
                    top: 0;
                    height: calc(#{$glyph_height} / 2);
                }

                &.after {
                    top: calc(#{$glyph_height} / 2);
                    bottom: 0;
                    height: calc(100% - #{$glyph_height} / 2);
                }
            }
        }

        .funnel-step-metadata {
            // .funnel-step-metadata reusable class for components that contain metadata for the funnel (e.g. time to convert or conversion steps)
            display: flex;
            flex-wrap: wrap;
        }

        header,
        footer {
            display: flex;
            align-items: center;
            line-height: $glyph_height;
        }

        header {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;

            .funnel-step-title {
                font-weight: bold;

                @extend %mixin-text-ellipsis;
            }

            button {
                margin-left: 0.375rem;
            }
        }
    }

    .funnel-bar-wrapper {
        display: flex;
        flex-direction: row;
        height: 32px;
        margin: 4px 0;
        background-color: var(--border-3000);
        border-radius: var(--radius);

        .funnel-bar {
            position: relative;
            height: 100%;
            background: var(--primary-3000);
            transition: width 0.2s ease, height 0.2s ease;

            &.first {
                border-radius: var(--radius) 0 0 4px;
            }

            &.last {
                border-radius: 0 4px 4px 0;
            }

            &.only {
                border-radius: var(--radius);
            }

            .funnel-bar-percentage {
                position: absolute;
                top: 8px;
                font-weight: bold;
                line-height: 16px;
                color: #fff;

                &.inside {
                    right: $label_position_offset;
                }

                &.outside {
                    left: calc(100% + #{$label_position_offset});
                    color: var(--text-3000);
                }
            }
        }
    }
}

// Hide .funnel-bar within InsightCards for snapshots, due to flakiness
.storybook-test-runner .InsightCard .funnel-bar {
    display: none;
}
